package com.example.arcgismodel;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import com.esri.arcgisruntime.ArcGISRuntimeEnvironment;
import com.esri.arcgisruntime.layers.ArcGISMapImageLayer;
import com.esri.arcgisruntime.layers.WmsLayer;
import com.esri.arcgisruntime.mapping.ArcGISMap;
import com.esri.arcgisruntime.mapping.BasemapStyle;
import com.esri.arcgisruntime.mapping.Viewpoint;
import com.esri.arcgisruntime.mapping.view.MapView;
import com.esri.arcgisruntime.ogc.wms.WmsService;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ArcGISRuntimeEnvironment.setApiKey("AAPK16f373c3c78b4649a69e3a835c5d3882R5BVdgvKpdtCoQiyCZ2tmmmDBdceVK9Gz2duNf4Fy1Q4Uo-LUbfAvSR6NuKBOr2I");

        MapView mMapView = findViewById(R.id.mapView);
        ArcGISMap map = new ArcGISMap(BasemapStyle.ARCGIS_TOPOGRAPHIC);
        mMapView.setMap(map);
        mMapView.setViewpoint(new Viewpoint(-42.31384, 146.82129, 10000));

        List<String> wmsLayerNames = new ArrayList<>();
        wmsLayerNames.add("tasmania");

        // create a new WMS layer displaying the specified layers from the service
        WmsLayer wmsLayer = new WmsLayer("http://106.13.115.56:8080/geoserver/wms?service=WMS&version=1.1.0&request=GetCapabilities", wmsLayerNames);
        wmsLayer.setPreferredImageFormat(ArcGISMapImageLayer.ImageFormat.PNG);
        wmsLayer.setVisible(true);
        wmsLayer.setOpacity(0.5f);

        // add the layer to the map
        map.getOperationalLayers().add(wmsLayer);

    }
}